package org.cpplib;

import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.ptr.ByteByReference;
import com.sun.jna.Structure;
import org.cpplib.Student;

public class MyClass {


    public interface CLibrary extends Library {

        CLibrary INSTANCE = (CLibrary)Native.loadLibrary("D://test//TestDLLQT",
                CLibrary.class);

        int add(int a,int b);

        byte charTest(String ch);

        //        Pointer MyClass_ctor(int nb);
        PointerByReference MyClass_ctor(int nb);

        int MyClass_getValue(PointerByReference self);

        void MyClass_increment(PointerByReference self);

        int structTest(Student s);

        void printTest();



    }

//    private Pointer self;
    private PointerByReference self;

    public MyClass(int nb)
    {
        self = CLibrary.INSTANCE.MyClass_ctor(nb);
    }

    public int getValue()
    {
        return CLibrary.INSTANCE.MyClass_getValue(self);
    }

    public void increment()
    {
        CLibrary.INSTANCE.MyClass_increment(self);
    }

    public int add(int a,int b)
    {
        return CLibrary.INSTANCE.add(a, b);
    }

    public byte charTest(String ch)
    {
        System.out.println("123213");
        return  CLibrary.INSTANCE.charTest(ch);
    }

    public int structTest(Student s)
    {
        return CLibrary.INSTANCE.structTest(s);
    }

    public void
    printTest()
    {
        CLibrary.INSTANCE.printTest();
    }

}
